var customerPhone = $("#customerPhone").val();
var customerPhone2 = $("#customerPhone2").val();
var phone = customerPhone;
var windowNameIndex = parent.layer.getFrameIndex(window.name); //获取窗口索引
if (customerPhone2 == null || customerPhone2 == "") {
    var w = phone;
    var listr = "";
    listr = '<div style="width: 30%"><span class="checkboxStyle">' +
        '<input class="checkboxClass" type="radio" value="' + w + '" name="about" ' +
        'id="click_' + w + '"></span>' +
        '<label for="click_' + w + '" class="labelStyle" ">' + w + '</label></div>';
    document.getElementById('customerPhoneBox').innerHTML = listr;
} else {
    phone = customerPhone + "," + customerPhone2;
    var w = phone.split(",");
    var listr = "";
    //把数据渲染到archiving_content容器里面
    //初始化科室下拉框
    for (var i = 0; i < w.length; i++) {
        listr += '<div style="width: 30%"><span class="checkboxStyle">' +
            '<input class="checkboxClass" type="radio" value="' + w[i] + '" name="about" ' +
            'id="click_' + w[i] + '"></span>' +
            '<label for="click_' + w[i] + '"  class="labelStyle"">' + w[i] + '</label></div>';
    }
    document.getElementById('customerPhoneBox').innerHTML = listr;
}
;

$("#customerPhoneBox").on('click', '.checkboxStyle', function () {
    $(this).addClass('selection').parent().siblings().children('.checkboxStyle').removeClass('selection');
});

//修改主号
function setZphone() {
    var customerPhone = $("input[name='about']:checked").val();
    var customerPhone2 = $("input[name='about']").val();
    var customerId = $("#customerId").val();
    if (customerPhone == "" || customerPhone == null) {
        alert("请选择手机号！")
    } else {
        $.ajax({
            url: Feng.ctxPath + "/customer/setZphone",
            type: "post",
            data: {
                "customerPhone": customerPhone,
                "customerPhone2": customerPhone2,
                "customerId": customerId
            },
            success: function (data) {
                Feng.success("修改成功!");
                window.parent.Customer.table.refresh();
                parent.layer.close(windowNameIndex);
            },
            error: function (data) {
                alert('没有权限，请联系系统管理员!');
                parent.layer.close(windowNameIndex);
            }
        });
    }
};

//修改主号
function deletePhone() {
    var customerPhone = $("input[name='about']:checked").val();
    var customerPhone2 = $("input[name='about']").val();
    var customerId = $("#customerId").val();
    if (customerPhone == "" || customerPhone == null) {
        alert("请选择手机号！")
    } else {
        $.ajax({
            url: Feng.ctxPath + "/customer/deletePhone",
            type: "post",
            data: {
                "customerPhone": customerPhone,
                "customerPhone2": customerPhone2,
                "customerId": customerId
            },
            success: function (data) {
                Feng.success("删除成功!");
                window.parent.Customer.table.refresh();
                parent.layer.close(windowNameIndex);
            },
            error: function (data) {
                alert('没有权限，请联系系统管理员!');
                parent.layer.close(windowNameIndex);
            }
        });
    }
}

//添加
function addPhone() {
    var customerPhone3 = $("#customerPhone3").val();
    var customerId = $("#customerId").val();
    if (customerPhone3 == "" || customerPhone3 == null) {
        alert("请填入手机号！")
    } else {
        $.ajax({
            url: Feng.ctxPath + "/customer/addPhone",
            type: "post",
            data: {
                "customerPhone3": customerPhone3,
                "customerId": customerId
            },
            success: function (data) {
                if (data == 0) {
                    Feng.success("添加失败，此手机号已存在!");
                } else {
                    Feng.success("添加成功!");
                    window.parent.Customer.table.refresh();
                    parent.layer.close(windowNameIndex)
                }
            },
            error: function (data) {
                alert('没有权限，请联系系统管理员!');
                parent.layer.close(windowNameIndex);
            }
        });
    }
}